package service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import dao.PermissionDao;
import domain.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionService {

    @Autowired
    private PermissionDao permissionDao;

    //查询所有：新增role时查询
    public List<Permission> findAllPermission(){
        return permissionDao.findAll();
    }


    //分页查询
    public PageInfo<Permission> findAll(int pageNum,int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<Permission> all = permissionDao.findAll();
        PageInfo<Permission> pageInfo = new PageInfo(all);
        return pageInfo;
    }

    //新增权限
    public void addPermission(Permission permission){
        permissionDao.add(permission);
    }

    //根据id查询权限
    public Permission findPermissionById(int id){
        return permissionDao.findById(id);
    }

    //修改权限信息
    public void updatePermission(Permission permission){
        permissionDao.update(permission);
    }

}
